<?php
require_once '../../controller/contratos/' . basename(__FILE__);
$pagina[0] = array('Contratos', '../../view/contratos/pesquisar.php');
$pagina[1] = array(( $id > 0 ) ? 'Editar Contrato' : 'Inserir Contrato');
require_once '../../template/header.php';
?>
<ul class="navmenu">
	<li><a class="voltar" href="pesquisar.php">Voltar</a></li>
    
    <?php //if ( $usuario->isAuthorized( Operacao::CONTRATO_CADASTRAR )): ?>
    <?php if (FluxoContrato::isAuthorized('cadastrar', $contrato) OR
    		  FluxoContrato::isAuthorized('alterar', $contrato)): ?>
    <li><a class="novo" href="cadastrar.php">Novo</a></li>
    <?php endif; ?>
    
    <?php require_once 'helper_abas.php'; ?>
</ul>
<div id="conteudo">

<?php require_once 'helper_brevidade.php' ?>

<?php TMensagens::exibirStatus($erro, $sucesso) ?>

<?php SInfoContrato::gerarCabecalho($contrato) ?>

<?php require_once 'helper_situacao.php'; ?>

<form method="post" action="<?php echo basename(__FILE__); if ( $id ) echo '?id=' . $id; ?>">
	<table>
		<tr>
			<td>Orgão</td>
			<td><select name="ddlOrgaoID" id="ddlOrgaoID" class="textoMedio" <?php echo $readOnly ?>>
			<?php TSelect::MontaDropDownList(Listas::RetornarOrgaos(), $contrato->orgaoid); ?>
			</select></td>
		</tr>
		<tr>
			<td>Empresa</td>
			<td><select name="ddlEmpresaID" class="textoMedio" <?php echo $readOnly ?>>
			<?php TSelect::MontaDropDownList(Listas::RetornarEmpresas(), $contrato->empresaid); ?>
			</select></td>
		</tr>
		<tr>
			<td>Número SIOF</td>
			<td><input type="text" id="txtNumeroSIOF2" name="txtNumeroSIOF" maxlength="50"
				class="textoMedio" value="<?php echo $contrato->numerosiof; ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Número Contrato no Orgão</td>
			<td><input type="text" id="txtNumeroOrgao" name="txtNumeroOrgao" maxlength="50"
				class="textoMedio" value="<?php echo $contrato->numeroorgao;?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Tipo de Contrato</td>
			<td><select name="ddlTipoContratoID" id="ddlTipoContratoID"
				class="textoMedio" <?php echo $readOnly ?>>
				<?php TSelect::MontaDropDownList(Listas::RetornarTiposContrato(), $contrato->tipocontratoid); ?>
			</select></td>
		</tr>
		<tr>
			<td>Modalidade Licitação</td>
			<td><select name="ddlModalidadeLicitacaoID"
				id="ddlModalidadeLicitacaoID" class="textoMedio" <?php echo $readOnly ?>>
				<?php  TSelect::MontaDropDownList(Listas::RetornarModalidadesDeLicitacao(), $contrato->modalidadelicitacaoid); ?>
			</select></td>
		</tr>
		<tr>
			<td>Número Licitaçao/Dispensa</td>
			<td><input type="text" name="txtNumeroLicitacao" maxlength="20"
				id="txtNumeroLicitacao" class="textoMedio maskNumeroLicitacao"
				value="<?php echo $contrato->numerolicitacao; ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Objeto</td>
			<td><textarea name="txtObjeto" id="txtObjeto" rows="4"
				class="textoGrande" <?php echo $readOnly ?>><?php echo $contrato->objeto; ?></textarea></td>
		</tr>
		<tr>
			<td>Data Início</td>
			<td><input type="text" name="txtDataInicio"
				id="txtDataInicio" class="textoPequeno maskData" maxlength="10"
				value="<?php echo TUtils::DataEnPt($contrato->datainicio); ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Data Fim</td>
			<td><input type="text" name="txtDataFim" id="txtDataFim"
				class="textoPequeno maskData" maxlength="10"
				value="<?php echo TUtils::DataEnPt($contrato->datafim); ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Dias Vigência</td>
			<td><input type="text" name="txtDiasVigencia" id="txtDiasVigencia"
				class="textoPequeno" maxlength="8"
				value="<?php echo $contrato->diasvigencia; ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Valor Mensal</td>
			<td><input type="text" name="txtValorMensal"
				class="textoPequeno maskMoeda"
				value="<?php echo $contrato->valormensal; ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<tr>
			<td>Valor Global</td>
			<td><input type="text" name="txtValorGlobal"
				class="textoPequeno maskMoeda"
				value="<?php echo $contrato->valorglobal; ?>" <?php echo $readOnly ?>/></td>
		</tr>
		<?php if ($contrato->isAditivo() AND $readOnly == ''): ?>
		<tr>
			<td>Motivos Aditivo</td>
			<td>
				<?php if ( $listaMotivosAditivo ): ?>
        		<ul>
        			<?php foreach ( $listaMotivosAditivo as $m ): ?>
        			<?php $checked = ($m['checked']) ? 'checked' : '' ?>
        			<li>
        				<input type="checkbox" name="chkMotivosAditivo[]" value="<?php echo $m['motivoaditivoid'] ?>" <?php echo $checked ?>/>
        				<?php echo $m['descricao'] ?>
    				</li>
        			<?php endforeach; ?>
        		</ul>
        		<?php endif; ?>
			</td>
		</tr>
		<?php endif ?>
	</table>
	<?php if ( $readOnly == '' ): ?>
	<p class="botoeira">
       	<input type="submit" name="btnAcao" title="Salvar" value="Salvar" />&nbsp;
    </p>
    <?php endif; ?>
	<input type="hidden" name="id" value="<?php echo $contrato->contratoid; ?>" />
</form>
</div>
			<?php require_once '../../template/footer.php'; ?>